Skip to content

solver warmstart #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

solver warmstart #5

wants to merge 3 commits into from

Conversation

thowell
Copy link
Collaborator

@thowell thowell commented Mar 20, 2025

the existing solver implementation initializes qacc with qacc_warmstart.

this pr:

  • if the warmstart disableflags option is not set, solve compares the costs associated with qacc_smooth and qacc_warmstart in order to determine the initialization for qacc
  • if the warmstart disableflags option is set, qacc is initialized with qacc_smooth

benchmarking:

mjwarp-testspeed --function=solve --mjcf=humanoid/humanoid.xml --batch_size=8192 --iterations=1 --ls_iterations=5 --solver=newton

this pr:

Summary for 8192 parallel rollouts

 Total JIT time: 0.15 s
 Total simulation time: 8.48 s
 Total steps per second: 966,092
 Total realtime factor: 4,830.46 x
 Total time per step: 1035.10 ns

main:

Summary for 8192 parallel rollouts

 Total JIT time: 0.14 s
 Total simulation time: 7.91 s
 Total steps per second: 1,036,164
 Total realtime factor: 5,180.82 x
 Total time per step: 965.10 ns

@erikfrey
Copy link
Collaborator

This is an interesting scenario! It seems to suggest we should not follow the exact same behavior here as MuJoCo because the cost of the thread divergence is higher than the cost of the occasional extra solver step. That's my read at least.

I would suggest holding off on this and revisiting after we implement logging and measuring solver statistics, because then we can get a really good intuition on how early returning relates to step perf and the tradeoffs for this kind of thread divergence.

btaba pushed a commit to btaba/mujoco_warp that referenced this pull request May 1, 2025
@erikfrey
Copy link
Collaborator

@thowell let's close this for now unless you're planning to come back to it soon?

@thowell thowell marked this pull request as ready for review June 1, 2025 11:51
@thowell
Copy link
Collaborator Author

thowell commented Jun 1, 2025

@erikfrey the pr is updated with a simplified warmstart option for the solver

@erikfrey
Copy link
Collaborator

@thowell maybe in this same PR we should do some testing and compare solver iterations for MuJoCo Warp vs. MuJoCo C.

My expectation is that we are close to the number of solver iterations compared to MJC, let's say at most 1 more solver iteration for constraints that converge quickly, maybe a a few more for solutions that take a lot of iterations to converge quickly. And that warmstart helps as much in MJWarp as it does in MJC. Do you want to do that analysis over a few scenes?

Maybe as part of that analysis we should add printing solver stats to mjwarp-testspeed - WDYT?

@erikfrey
Copy link
Collaborator

@thowell what's the status of this PR?

@thowell
Copy link
Collaborator Author

thowell commented Jul 24, 2025

@erikfrey the changes in this pr are now quite minimal, essentially just an option to initialize the solve qacc with qacc_smooth instead of qacc_warmstart. my preference would be to merge this pr as-is and then investigate solver iterations for difference scenarios in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants